!function(){"use strict";var e,t=(function(e){function t(){return e.exports=t=Object.assign||function(e){for(var t=1;tn;n++)try{t=new ActiveXObject(r[n]);break}catch(e){}}return t.onreadystatechange=function(){4===t.readyState&&e&&e(t.responseText)},t},get:function(e,t){var n=i.load(t);n.open("GET",e,!0),n.send("")},post:function(e,t,n){var o=i.load(n);o.open("POST",t,!0),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.send(e)},postJSON:function(e,t,n){var o=i.load(n);o.open("POST",t,!0),o.setRequestHeader("Content-type","application/json"),o.send(e)}},s={},a=OptiMonkRegistry.baseUrl+"/error/log";function c(e){i.post("message="+encodeURIComponent(JSON.stringify(e)),a)}function l(e){return!!s[e.message]}function d(e){s[e.message]=1}const u={sendException(e){if(l(e))return;d(e);c(function(e){var t,n,o;return{message:e.message,stack:e.stack,userAgent:navigator.userAgent,url:window.location.href,name:e.name,line:e.lineNumber||e.number,timezone:null==(t=window.Intl)||null==t.DateTimeFormat||null==(n=(o=t.DateTimeFormat()).resolvedOptions)?void 0:n.call(o).timeZone}}(e))},sendEventError(e){if(l(e))return;d(e);var t;c({message:(t=e).message,stack:t.error?t.error.stack:"",userAgent:navigator.userAgent,url:window.location.href,errorEvent:t,file:t.filename})}};var p=String.fromCharCode,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g={};const m={compressToBase64:function(e){if(null==e)return"";var t=m._compress(e,6,(function(e){return h.charAt(e)}));switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(e){return null==e?"":""==e?null:m._decompress(e.length,32,(function(t){return function(e,t){if(!g[e]){g[e]={};for(var n=0;n>=1}else{for(r=1,o=0;o>=1}0==--u&&(u=Math.pow(2,h),h++),delete a[d]}else for(r=s[d],o=0;o>=1;0==--u&&(u=Math.pow(2,h),h++),s[l]=p++,d=String(c)}if(""!==d){if(Object.prototype.hasOwnProperty.call(a,d)){if(d.charCodeAt(0)<256){for(o=0;o>=1}else{for(r=1,o=0;o>=1}0==--u&&(u=Math.pow(2,h),h++),delete a[d]}else for(r=s[d],o=0;o>=1;0==--u&&(u=Math.pow(2,h),h++)}for(r=2,o=0;o>=1;for(;;){if(m<<=1,f==t-1){g.push(n(m));break}f++}return g.join("")},_decompress:function(e,t,n){var o,r,i,s,a,c,l,d=[],u=4,h=4,g=3,m="",f=[],w={val:n(0),position:t,index:1};for(o=0;o<3;o+=1)d[o]=o;for(i=0,a=Math.pow(2,2),c=1;c!=a;)s=w.val&w.position,w.position>>=1,0==w.position&&(w.position=t,w.val=n(w.index++)),i|=(s>0?1:0)*c,c<<=1;switch(i){case 0:for(i=0,a=Math.pow(2,8),c=1;c!=a;)s=w.val&w.position,w.position>>=1,0==w.position&&(w.position=t,w.val=n(w.index++)),i|=(s>0?1:0)*c,c<<=1;l=p(i);break;case 1:for(i=0,a=Math.pow(2,16),c=1;c!=a;)s=w.val&w.position,w.position>>=1,0==w.position&&(w.position=t,w.val=n(w.index++)),i|=(s>0?1:0)*c,c<<=1;l=p(i);break;case 2:return""}for(d[3]=l,r=l,f.push(l);;){if(w.index>e)return"";for(i=0,a=Math.pow(2,g),c=1;c!=a;)s=w.val&w.position,w.position>>=1,0==w.position&&(w.position=t,w.val=n(w.index++)),i|=(s>0?1:0)*c,c<<=1;switch(l=i){case 0:for(i=0,a=Math.pow(2,8),c=1;c!=a;)s=w.val&w.position,w.position>>=1,0==w.position&&(w.position=t,w.val=n(w.index++)),i|=(s>0?1:0)*c,c<<=1;d[h++]=p(i),l=h-1,u--;break;case 1:for(i=0,a=Math.pow(2,16),c=1;c!=a;)s=w.val&w.position,w.position>>=1,0==w.position&&(w.position=t,w.val=n(w.index++)),i|=(s>0?1:0)*c,c<<=1;d[h++]=p(i),l=h-1,u--;break;case 2:return f.join("")}if(0==u&&(u=Math.pow(2,g),g++),d[l])m=d[l];else{if(l!==h)return null;m=r+r.charAt(0)}f.push(m),d[h++]=r+m.charAt(0),r=m,0==--u&&(u=Math.pow(2,g),g++)}}},f=function(e,t,n){return JSON.stringify(e,t,n)},w=function(e,t){return JSON.parse(e,t)},y=function(e,t){if("string"!=typeof e)return decodeURIComponent(e);var n,o,r,i="",s=0;for(void 0===t&&(t=0),o=(n=e.split(/(%(?:d0|d1)%.{2})/)).length;s576)){t=!1;break}}return t},merge:E,getProp:function e(t,n,o){return(t=t[(n=Array.isArray(n)?n:n.split("."))[0]])&&n.length>1?e(t,n.slice(1),o):void 0===t?o:t}});const O={XMLHttpRequest:window.XMLHttpRequest,fetch:window.fetch,Promise:window.Promise,Date:window.Date};let _;function b(){const e=document.querySelector('iframe[id="__OM_native_iframe"]');if(e)_=e;else{const e=document.createElement("iframe");_=e,_.style.display="none",_.id="__OM_native_iframe",document.body.appendChild(_)}}try{b(),_&&(O.XMLHttpRequest=function(){_&&"BODY"===_.parentNode.nodeName||b();let e=_.contentWindow.XMLHttpRequest;return"function"!=typeof e&&(e=window.XMLHttpRequest),new e(...arguments)},O.fetch=function(){const e=_.contentWindow.fetch||window.fetch;return e(...arguments)},O.Promise=_.contentWindow.Promise||window.Promise,O.Date=_.contentWindow.Date||window.Date)}catch(e){}const A=e=>m.compressToBase64(JSON.stringify(e)),R="optiMonkClient",M=(e,t)=>{const n=t[e];if(Object.keys(n.ca).length<=14)ee.local.setItem(R,A(t));else{((e,t,n)=>{n.forEach((function(e,n){0!==n&&ee.local.setItem("optiMonkClient_"+t+"_"+n,A(e))}));const o=JSON.parse(JSON.stringify(e));o[OptiMonkRegistry.account].ca=n[0],ee.local.setItem(R,A(o))})(t,e,((e,t)=>{const n=[];let o=[],r=1;for(const i in e)if(e.hasOwnProperty(i)){const s=e[i];s.caId=i,o.push(s),r%t==0&&(n.push(o),o=[]),r++}return n.push(o),n})(n.ca,14))}(()=>{const e=ee.local.getItemSlicesRaw(R);for(let t=0,n=e.length;t30}catch(e){console.error("[OM] Multi account cookie deletion error",e)}n&&(delete t[e],console.log("delete account cookie",e))})),t[e]={},t;if(Array.isArray(t[e].ca)){const o=ee.local.getItemSlicesRaw("optiMonkClient"),r=t[e].ca;for(let e=0,t=o.length;e{const e=document.querySelector('form[action^="/cart/add"][data-delm-is-primary-form="true"]')?document.querySelectorAll('form[action^="/cart/add"][data-delm-is-primary-form="true"]'):document.querySelectorAll('form[action^="/cart/add"]'),t=[...e].find((e=>e.getAttribute("data-product-id")||e.getAttribute("data-productid")));return null!=t?t:null==e?void 0:e[0]},B=function(){if(window.ShopifyAnalytics){const e=J();if(e){const t=e.querySelector('[name="id"]');if(t)return t.value}if("undefined"!=typeof URLSearchParams){const e=new URLSearchParams(window.location.search).get("variant");if(e)return e}return F(window.ShopifyAnalytics,"meta.selectedVariantId")||null}return window.ShopRenter&&F(window.ShopRenter,"product.id")||null},V=()=>{var e;const t=J(),n=(null==t||null==t.querySelectorAll?void 0:t.querySelectorAll('select[name="id"] option'))||[];return null==(e=Array.from(n))||null==e.map?void 0:e.map((e=>({id:e.value})))},H=function(){let e=null,t=B();if(window.ShopifyAnalytics){e=F(window.ShopifyAnalytics,"meta.product.id");const n=V(),o=n.length?n:F(window.ShopifyAnalytics,"meta.product.variants");if(o){o.find((function(e){return""+e.id==""+t}))||(t=null)}}else window.ShopRenter&&(t=F(window.ShopRenter,"product.id"),e=F(window.ShopRenter,"product.parent.id")||t);return e&&t?{productId:""+e,variantId:""+t}:null};n._assets=n._assets||{},n.loadAsset=function(e,t,o){function r(t){let o;for(;o=n._assets[e].cbs.shift();)o(t)}if(n._assets[e])return n._assets[e].loaded?void o():void n._assets[e].cbs.push(o);n._assets[e]={loaded:!1,cbs:[]},n._assets[e].cbs.push(o);try{let o=null,i=null;"js"===t?(o=document.createElement("script"),o.src=e,i=document.body):"css"===t&&(o=document.createElement("link"),o.href=e,o.rel="stylesheet",o.type="text/css",i=document.getElementsByTagName("head")[0]),o&&i&&(o.onload=function(){n._assets[e].loaded=!0,r()},o.onerror=function(e){r(e)},i.appendChild(o))}catch(e){r(e)}},n.loadScript=function(e,t){"/"!==e.charAt(0)&&(e="/"+e),this.loadAsset(OptiMonkRegistry.getAssetUrlFor(e),"js",t)};var K=Object.freeze({__proto__:null,each:function(e,t){let n;for(n in e)e.hasOwnProperty(n)&&"length"!==n&&t(n,e[n])},getCookie:T,updateCampaignCookie:(e,t,n)=>{const o=T();o[e].ca[t]=n,M(e,o),OptiMonkRegistry.Cookie.ca[t]=n},updateCampaignCookies:(e,t)=>{var n;const o=T();null!=(n=o[e])&&n.ca||(o[e].ca={}),Object.keys(t).forEach((n=>{o[e].ca[n]=t[n]})),M(e,o)},saveCookie:function(){const e=T();e[OptiMonkRegistry.account]=OptiMonkRegistry.Cookie;const t=e[OptiMonkRegistry.account].ca;if(Object.keys(t).length>14){const n=[];let o=[],r=1;for(const e in t)if(t.hasOwnProperty(e)){const i=t[e];i.caId=e,o.push(i),r%14==0&&(n.push(o),o=[]),r++}n.push(o),n.forEach((function(e,t){t&&ee.local.setItem("optiMonkClient_"+OptiMonkRegistry.account+"_"+t,A(e))}));const i=JSON.parse(JSON.stringify(e));i[OptiMonkRegistry.account].ca=n[0],ee.local.setItem("optiMonkClient",A(i))}else ee.local.setItem("optiMonkClient",A(e));const n=ee.local.getItemSlicesRaw("optiMonkClient");for(let e=0,t=n.length;e{const n=document.querySelector("html");D(n,"optimonk#campaign-conversion",{campaignId:e,elementDetails:t})},uuid:j,requestIdleCallback:function(e,t){if(window.requestIdleCallback)return window.requestIdleCallback(e,t);const n=Date.now(),o=t&&"number"==typeof t.timeout?t.timeout:50;return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,o-(Date.now()-n))})}),1)},cancelIdleCallback:function(e){if(window.cancelIdleCallback)return window.cancelIdleCallback(e);clearTimeout(e)},_get:F,addScript:q,sendLoadRequest:U,sendMetrics:function(e,t){t.frontend=!0,t.device=OptiMonkRegistry.isMobile?"mobile":"desktop",O.fetch(OptiMonkRegistry.baseUrl+"/metrics",{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:OptiMonkRegistry.account,event:"frontend-"+e,properties:t})})},getAddToCartForm:J,getSelectedVariantId:B,getShopifyVariantsFromDOM:V,getViewedProductIds:H,getExperimentalSetting:function(e){var t;return null==(t=n.experimentalSettings)?void 0:t[e]}});const X=function(e,t,n){return JSON.stringify(e,t,n)},W=function(e,t){return JSON.parse(e,t)},z=function(e,t){return"object"!=typeof t?function(e,t){if("string"!=typeof e)return decodeURIComponent(e);let n,o="",r=0;const i=e.split(/(%(?:d0|d1)%.{2})/);for(let e=i.length;r{const e="x-om-web-selector-restore-token",t="x-om-web-selector-token";performance.getEntriesByType("navigation").map((e=>"reload"===e.type)).every((e=>e))||localStorage.removeItem(e);const n=new URLSearchParams(location.search).get(t),o=localStorage.getItem(t)||localStorage.getItem(e);return n||o},$=function(e){return"object"==typeof e&&(e=X(e)),navigator.userAgent.match(/^Opera.* Version\/12.*/)?encodeURIComponent(e):e},Y={getItem(e){const t=document.cookie.match(new RegExp(e+"=([^;]+)"));return t?decodeURIComponent(t[1]):null},getItemSlices(e,t){const n=new RegExp(e+"_"+OptiMonkRegistry.account+"_[0-9]+=([^;]+)\\;?","gm");let o,r=[];for(;o=n.exec(document.cookie);){const e="function"==typeof t?t(o[1]):o[1];r=r.concat(JSON.parse(decodeURIComponent(e)))}return r},getItemSlicesRaw(e){const t=new RegExp("("+e+"_"+OptiMonkRegistry.account+"_[0-9]+)=([^;]+)\\;?","gm"),n=[];let o;for(;o=t.exec(document.cookie);)n.push({key:o[1],value:o[2]});return n},removeItem:e=>!!Y.hasItem(e)&&(document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;",!0),hasItem:e=>!!e&&new RegExp("(?:^|;\\s*)"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie),setItem(e,t){const n=new Date;let o=$(t);n.setUTCFullYear(n.getUTCFullYear()+1),o+="; expires="+n.toUTCString(),document.cookie=e+"="+o+";path=/;"}},Z={setItem(e,t){const n=$(t);document.cookie=e+"="+n+";path=/;"},getItem:e=>Y.getItem(e),getItemSlices:e=>Y.getItemSlices(e),hasItem:e=>Y.hasItem(e),removeItem:e=>Y.removeItem(e)},Q={},ee={local:Y,session:Z,CampaignCookieCollection:{add(e){Q[e.getCampaignId()]=e},getByCampaignId:e=>Q[e],getAllAsArray:()=>Object.keys(Q).map((e=>Q[e]))}};let te=ee.local.setItem,ne=ee.local.getItem,oe=ee.local.getItemSlices,re=ee.local.removeItem,ie=ee.local.hasItem,se=ee.session.setItem,ae=ee.session.getItem,ce=ee.session.getItemSlices,le=ee.session.removeItem,de=ee.session.hasItem;"object"==typeof localStorage&&(te=function(e,t){localStorage.setItem(e,X(t))},ne=function(e){return W(localStorage.getItem(e),z)},oe=function(e){return W(localStorage.getItemSlices(e),z)},re=function(e){return localStorage.removeItem(e),!0},ie=function(e){return null!==ne(e)},se=function(e,t){sessionStorage.setItem(e,X(t))},ae=function(e){return W(sessionStorage.getItem(e),z)},ce=function(e){return W(sessionStorage.getItemSlices(e),z)},le=function(e){return sessionStorage.removeItem(e),!0},de=function(e){return null!==ae(e)});const ue={getItem:e=>ne(e),setItem(e,t){te(e,t)},getItemSlices:e=>oe(e),removeItem:e=>re(e),hasItem:e=>ie(e)},pe="OptiMonkPreviouslyViewedPages",he={local:ue,session:{getItem:e=>ae(e),setItem(e,t){se(e,t)},getItemSlices:e=>ce(e),removeItem:e=>le(e),hasItem:e=>de(e)},getPreviouslyViewedPages:()=>ue.getItem(pe)||{},setPreviouslyViewedPages:e=>{ue.setItem(pe,e)},deletePreviouslyViewedPages:()=>{ue.removeItem(pe)}},ge={load(){const e=n.ayepromise.defer();return this.Loader.load(e),e.promise},Loader:{load(e){e.resolve()}}};class me{constructor(){this.type="custom",this._cookieNames=[]}getShopId(){return null}hasCookie(){let e=!1;for(let t=0;t-1)return!0}}return!1}}class Ee extends me{constructor(){super(...arguments),this.type="unas"}check(){return!!window.unas_shop_url}}class Ce extends me{constructor(){super(...arguments),this.type="wordpress"}check(){const e=Array.from(document.querySelectorAll("link"));for(let t=0;t-1,t=n.href.indexOf("/wp-includes/")>-1;if(e||t)return!0}}return!1}}class Oe extends me{constructor(){super(...arguments),this.type="drupal"}check(){return!!window.Drupal}}let _e=!1;const be=[];function Ae(){if(!_e)try{be.push(new fe),be.push(new we),be.push(new ye),be.push(new ve),be.push(new Ie),be.push(new ke),be.push(new Se),be.push(new Ee),be.push(new Ce),be.push(new Oe),_e=!0}catch(e){console.error("[Engine] Error occurred when instantiating detectors",e)}}function Re(){_e||Ae();for(let e=0;e{const e=ee.local.getItem("__kla_id"),t=ee.local.getItem("optiMonkClientId");return{account:"undefined"!=typeof OptiMonkRegistry?OptiMonkRegistry.account:null,isKlaviyoDetected:!!e||!!window._learnq,clientId:t,hostname:location.hostname}};let xe=!1;function Ne(e){const t=new n.native.XMLHttpRequest;return t.open("POST",OptiMonkRegistry.baseUrl+"/analytics/"+e,!0),t.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),t}const Le={initialize(){xe||(Me.initialize(),xe=!0)},collect(){const e=Me.getInfo();return{account:OptiMonkRegistry.account,platform:e.type,shopId:e.shopId,hostname:location.hostname}},getKlaviyoInfo:Te,sendIsKlaviyoDetected(){const e=Te();Ne("klaviyo").send("data="+JSON.stringify(e))},send(){if(!xe)throw new Error("[SiteInfo] Not initialized");const e=Le.collect();Ne("siteinfo").send("data="+JSON.stringify(e))}};var Pe,De,je,Fe=1;const qe={postMessage:function(e,t,n){t&&(n=n||parent,window.postMessage?n.postMessage(e,t.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):t&&(n.location=t.replace(/#.*$/,"")+"#"+ +new Date+Fe+++"&"+e))},receiveMessage:function(e,t){window.postMessage?(e&&(je=function(n){if("string"==typeof t&&n.origin!==t||"[object Function]"===Object.prototype.toString.call(t)&&!1===t(n.origin))return!1;e(n)}),window.addEventListener?window[e?"addEventListener":"removeEventListener"]("message",je,!1):window[e?"attachEvent":"detachEvent"]("onmessage",je)):(Pe&&clearInterval(Pe),Pe=null,e&&(Pe=setInterval((function(){var t=document.location.hash,n=/^#?\d+&/;t!==De&&n.test(t)&&(De=t,e({data:t.replace(n,"")}))}),100)))}},Ue=t({},C),Je={isApple:/Apple\ Computer/.test(navigator.vendor)},Be={isSafari:/Safari/.test(navigator.userAgent)&&Je.isApple,isIE:window.navigator.userAgent.indexOf("MSIE ")>0||!!window.navigator.userAgent.match(/Trident.*rv\:11\./),isFirefox:navigator.userAgent.toLowerCase().indexOf("firefox")>-1,isChrome:navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&navigator.vendor.indexOf("Google Inc")>-1&&-1===navigator.userAgent.indexOf("OPR")&&-1===navigator.userAgent.indexOf("SamsungBrowser")&&-1===navigator.userAgent.toLowerCase().indexOf("miui")},Ve={isIphone:/iPhone/.test(navigator.platform),isIpad:/iPad/.test(navigator.platform),isIpod:/iPod/.test(navigator.platform)};const He=[],Ke=function(e,t,n){e.addEventListener?(e.addEventListener(t,n,!1),He.push({obj:e,type:t,fn:n})):e.attachEvent?(e.attachEvent("on"+t,(function(){n.apply(e,new Array(window.event))})),He.push({obj:e,type:t,fn:n})):(e["on"+t]=n,He.push({obj:e,type:t,fn:n}))},Xe=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent?e.detachEvent("on"+t,n):e["on"+t]&&delete e["on"+t]};E(n,t({Logger:r,ErrorReporter:u,Cookie:ee,Storage:he,Data:ge,Engine:Me,SiteInfo:Le,messaging:qe,Util:Ue,ajax:i,LZString:m,native:O},Object.freeze({__proto__:null,vendor:Je,browser:Be,browserWithVersion:()=>{const e=navigator.userAgent;let t,n=e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])?(t=/\brv[ :]+(\d+)/g.exec(e)||[],{name:"IE",version:t[1]||""}):"Chrome"===n[1]&&(t=e.match(/\bOPR|Edge\/(\d+)/),null!=t)?{name:"Opera",version:t[1]}:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],t=e.match(/version\/(\d+)/i),null!=t&&n.splice(1,1,t[1]),{name:n[0],version:n[1]})},platform:Ve}),Object.freeze({__proto__:null,addedListeners:He,addListener:Ke,removeListener:Xe,removeAllListeners:function(){for(let e=0;e{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]))})),t.join("&")},_sendWithFetch(e,t){return new We(((n,o)=>{const r=this.__buildQueryString(t);ze(e+"?"+r).then((()=>n(!0))).catch((e=>o(e)))}))},_sendWithXHR(e,t){return new We(((n,o)=>{const r=this.__buildQueryString(t),i=new XMLHttpRequest;i.open("GET",e+"?"+r),i.send(),i.addEventListener("load",(()=>{if(200!==i.status){const e=i.response||i.responseText,t=new Error("XHR error - "+i.status+": "+e);return o(t)}return n(!0)}))}))},send(e,t){if(t.spentTime<6&&"visible"===document.visibilityState)try{return ze?this._sendWithFetch(e,t):this._sendWithXHR(e,t)}catch(e){this.log("cannot send data",e,t)}},calculateSpentTime(){try{const e=Date.now(),t=(e-this.timestamp)/1e3;return this.timestamp=e,parseInt(t.toFixed(0),10)}catch(e){this.log("calculateSpentTime error",e)}return 0},collectData(e){void 0===e&&(e="spent-time");const{pathname:t}=window.location;return{type:e,account:this.accountData.accountId,pathname:t,spentTime:this.calculateSpentTime()}},getUrl(){return this.accountData.baseUrl+"/analytics/timeSpentOnPage"},getIntervalTime:()=>OptiMonkRegistry.heartbeatInterval||5e3,reportNetworkTime(){if(window.performance&&window.performance.getEntriesByType){const e=this.getUrl(),t=OptiMonkRegistry.baseUrl+"/public/"+OptiMonkRegistry.account+"/js/preload.js",n=window.performance.getEntriesByType("resource");for(let o=0,r=n.length;o{this.sendVisit(),this.reportNetworkTime(),this.interval=setInterval((()=>{const e=this.getUrl(),t=this.collectData();this.send(e,t)}),this.getIntervalTime())}),0)},_init(){this.timestamp=Date.now();const{account:e,baseUrl:t}=OptiMonkRegistry;this.accountData={accountId:e,baseUrl:t}},init(){this.timestamp||(this._init(),this.registerSpentOnPage())},log(){for(var e=arguments.length,t=new Array(e),n=0;n=0||(r[n]=e[n]);return r};const Ye="BUILD_ADD_2_CART_CONFIG",Ze="HANDLE_ADD_2_CART_RESPONSE",Qe="BUILD_FETCH_CART_CONFIG",et="HANDLE_FETCH_CART",tt="info",nt="warn",ot="error",rt={[tt]:"INFO",log:"LOG",[nt]:"WARN",[ot]:"ERROR"},it="cart-module-empty",st="cart-module-not-empty",at="mobile-cart-empty",ct="mobile-cart-not-empty",lt={[it]:st,[st]:it,[at]:ct,[ct]:at};class dt{constructor(e,t){void 0===t&&(t=!1),this.forced=t,this.key=e,this.extraKeys=[],this.enabled=this.logEnabled()}child(e){const t=new dt(this.key,this.forced);return t.extraKeys=[...this.extraKeys,e],t}isSearchParam(e){return window.location.search.includes(e)}logEnabled(){if(this.forced)return!0;const e=this.isSearchParam("OMDebug"),t=this.isSearchParam("FULLDEBUG");return!(!e||!t)||(this.key?e&&this.isSearchParam(this.key):e)}log(e){if(void 0===e&&(e=tt),this.enabled){const r=""+[this.key,...this.extraKeys].join("][");for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o{let e;for(;e=OptiMonkRegistry.JFEvents.shift();){if(!Array.isArray(e)||"string"!=typeof e[0])return void console.warn("invalid pre-registered event: must be a tuple: [eventType, props]");const[t,n={}]=e;window.JFClientSDK.v2.registerCustomEvent(t,n)}OptiMonkRegistry.JFEvents.push===Array.prototype.push&&(OptiMonkRegistry.JFEvents.push=function(){for(var e=arguments.length,t=new Array(e),n=0;n{if(!Array.isArray(e)||"string"!=typeof e[0])return void console.warn("invalid invocation: must be called with a tuple: [eventType, props]");const[t,n={}]=e;window.JFClientSDK.v2.registerCustomEvent(t,n||{})})),window.JFClientSDK.v2.go()})};const gt=["url"],mt=["type"],ft={shoprenter:class extends ut{domUpdate(e,t,n){let{add:o,remove:r}=t;void 0===n&&(n=0),this.logger.log(tt,"domUpdate",...arguments),e&&(e.classList.add(o[n]),e.classList.remove(r[n]))}getClasses(e){this.logger.log(tt,"getClasses",...arguments);const t=e?[it,at]:[st,ct],n={add:t,remove:t.map((e=>lt[e]))};return this.logger.log(tt,{result:n}),n}updateDoms(e){this.logger.log(tt,"updateDoms",...arguments);const t=document.getElementById("module_cart"),n=document.querySelector(".mobile-cart-product-count");if(null!=e){const o=!(e>0),r=this.getClasses(o);this.domUpdate(t,r),this.domUpdate(n,r,1)}else{const e=this.getClasses(!0);this.domUpdate(!0,e),this.domUpdate(!0,e,1)}}createCartChangedEvt(e,t){return this.logger.log(tt,"createCartChangedEvt",...arguments),new CustomEvent("cartChanged",{detail:{data:t,cartToken:e,products:t.products}})}createAddToCartEvt(e,t,n){this.logger.log(tt,"createAddToCartEvt",...arguments);const o={id:n,sku:t.sku,price:t.priceWithoutCurrency,currency:t.currency,quantity:1,name:t.name};return this.logger.log(tt,{eventProduct:o}),new CustomEvent("AddToCart",{detail:{cartToken:e,product:o}})}setLocalStorageItem(){this.logger.log(tt,"setLocalStorageItem",...arguments),window.localStorage&&window.localStorage.setItem("cartModified",1)}[Ze](e){let{result:t,id:o}=e;this.logger.log(tt,Ze,...arguments);const r=t.cartToken||"",i=this.createCartChangedEvt(r,t);document.dispatchEvent(i);const s=t.products.find((e=>{let{product_id:t}=e;return""+o==""+t})),a=this.createAddToCartEvt(r,s,o);this.setLocalStorageItem(),document.dispatchEvent(a),this.updateDoms(t.countProducts),n.CartIntegration.dispatch(t,o)}[Ye](e,n){this.logger.log(tt,Ye,...arguments);const o={url:"/index.php?route=module/cart/callback",method:"POST"},r=new URLSearchParams({quantity:1,product_id:e.id});return this.logger.log(tt,{config:o,payload:r},...arguments),t({},o,n?{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()}:{payload:r.toString()})}cartItemMapper(e){const n=t({},e);return delete n.option,delete n.values,n}[et](e){let{result:t,getAdapter:n}=e;this.logger.log(tt,et,...arguments);const{item_count:o,token:r,total_discount:i,total_price:s,items:a}=t;n().then((e=>{e.Cart.clear(),t.items.forEach((t=>{e.Cart.add(t.id,this.cartItemMapper(t))}))})),pt("cartContent",{itemCount:o,items:JSON.stringify(a.map((e=>({id:e.id,quantity:e.quantity,price:e.price})))),token:r,totalPrice:s,totalDiscount:i})}[Qe](e,t){this.logger.log(tt,Qe,...arguments);const n={url:"/cart.json",method:"GET"};return t||(n.payload=null),this.logger.log(tt,{config:n}),n}},shopify:class extends ut{tryUpdateProductCount(e){const t=document.querySelectorAll(".omCartCount");for(let n=0;n{e.Cart.clear(),t.items.forEach((t=>{e.Cart.add(t.id,this.cartItemMapper(t))}))})),pt("cartContent",{itemCount:o,items:JSON.stringify(a.map((e=>({productId:e.product_id,variantId:e.variant_id,quantity:e.quantity,price:e.price})))),token:r,totalPrice:s,totalDiscount:i}),this.tryUpdateProductCount(t.item_count)}[Qe](e,t){this.logger.log(tt,Qe,...arguments);const n={url:"/cart.json",method:"GET"};return t||(n.payload=null),this.logger.log(tt,{config:n}),n}},BaseIntegration:ut},wt="TYPE_ADD_2_CART",yt="TYPE_FETCH_CART",vt={[wt]:{handler:Ze,requestConfigBuilder:Ye},[yt]:{handler:et,requestConfigBuilder:Qe}};class It{constructor(e){void 0===e&&(e=!1),this.adapter=null,this.logger=new dt("CI",e);const t=n.Engine.getType();this.integration=ft[t]?new ft[t](this.logger.child(t)):null,this.integration||this.logger.log(nt,"Not supported site engine")}createAdapter(){this.adapter||(this.adapter=new Promise((e=>{var t;null!=n&&null!=(t=n.Visitor)&&t.createAdapter?e(n.Visitor.createAdapter()):document.querySelector("html").addEventListener("optimonk#ready",(()=>{e(n.Visitor.createAdapter())}))})))}getAdapter(){return this.adapter}makeFetch(e){this.logger.log(tt,"makeFetch",...arguments);const n=$e(e,gt);return O.fetch(e.url,t({},n))}makeXHR(e){this.logger.log(tt,"makeXHR",...arguments);const t=n.ayepromise.defer(),o=new O.XMLHttpRequest;return o.open(e.method,e.url,!0),o.addEventListener("error",(e=>t.reject(e))),o.addEventListener("load",(()=>t.resolve(o.responseText))),o.send(e.payload),t.promise}async handle(e,n){this.logger.log(tt,"handle",...arguments);const o=await n.request,r=n.isFetch?await o.json():JSON.parse(o);return this.logger.log(tt,{result:r}),this.integration[e](t({result:r},n,{getAdapter:()=>this.adapter}))}makeRequest(e){const n=!!O.fetch;this.logger.log(tt,"makeRequest",...arguments);const o=$e(e,mt),r=vt[e.type];this.logger.log(tt,{methods:r,hasFetch:n});const i=this.integration[r.requestConfigBuilder](o,n);let s;return s=n?this.makeFetch(i):this.makeXHR(i),this.handle(r.handler,t({request:s,isFetch:n},o))}checkIntegration(){if(!this.integration){const e="Not supported site engine";throw this.logger.log(ot,e),new Error("Not supported site engine")}}addToCart(e){return this.checkIntegration(),this.logger.log(tt,"addToCart",...arguments),this.makeRequest({type:wt,id:e})}updateCartWith(e){this.logger.log(tt,"updateCartWith",...arguments);const t={added:[],failed:[]};return this.getAdapter().then((n=>{n.Cart.clear(),e.forEach((e=>{if(e.id&&e.quantity&&e.price){const o=this.integration?this.integration.cartItemMapper(e):e;n.Cart.add(e.id,o),t.added.push(o)}else t.failed.push(e)}))})),t}checkUpdateCartResult(e){if(!e)return this.logger.log(ot,"Result missing");e.failed.length&&this.logger.log(nt,"One or all mandatory property missing. Required properties: id, quantity, price",e.failed)}async updateVisitorCart(e){if(this.logger.log(tt,"updateVisitorCart",...arguments),this.createAdapter(),e){const t=this.updateCartWith(e);return this.checkUpdateCartResult(t),t}this.checkIntegration();const t=await this.makeRequest({type:yt});return n.triggerEvent(document.querySelector("html"),"optimonk#cart-update"),t}dispatch(e,t){this.logger.log(tt,"dispatch",...arguments),n.triggerEvent(document.querySelector("html"),"optimonk#cart-update",{data:e,productId:t})}}const kt=["browser_language","browser_name","browser_version","first_landing_page","first_visit_date","os_name","os_version","popup_last_seen","tz","tz_offset","utm_campaign","utm_content","utm_medium","utm_source","current_month_text_en"],St=function(e){void 0===e&&(e="en-US");return(new Date).toLocaleString(e,{month:"long"})},Et=()=>{const e=OptiMonk.Storage.local.getItem("OptiMonkVisitorAttributes"),n=(new Date).getTimezoneOffset()/60,o=t({browser_language:window.navigator.language},(()=>{const{browser_name:e,browser_version:t,os_name:n,os_version:o}=OptiMonkRegistry.ua||{};return{os_name:n,os_version:o,browser_name:e,browser_version:t}})(),(e=>{const t=["utm_medium","utm_source","utm_campaign","utm_content"],n=window.location.search.substring(1),o=new URLSearchParams(n),r={};for(const n of o.keys())!t.includes(n)||e&&void 0!==e[n]||(r[n]=o.get(n));return r})(e),{current_month_text_en:St(),current_month_text_hu:St("hu-HU"),tz:Intl.DateTimeFormat().resolvedOptions().timeZone,tz_offset:n<0?"UTC"+n:"UTC+"+n},(!e||void 0===e.first_landing_page)&&{first_landing_page:window.location.href},(!e||void 0===e.first_visit_date)&&{first_visit_date:(new Date).toISOString()});OptiMonk.Storage.local.setItem("OptiMonkVisitorAttributes",t({},e,o))},Ct=["thank_you","checkout_one_thank_you"];let[Ot,_t]=(()=>{let e;return[new Promise((t=>{let n=!1;e=e=>{if(n)throw new Error("Async value can only be set once");t(e),n=!0}})),e]})();const bt=()=>{var e;return null==(e=window)?void 0:e.JFClientSDK},At=()=>{const e=bt();try{e&&_t(!0)}catch(t){Ot=Promise.resolve(!!e)}};function Rt(e){const t=H();return t&&(window.JFClientSDK.v2.registerProductView(t),e)?window.JFClientSDK.v2.go().catch((function(e){console.log("An error occurred during JFClientSDK.v2.go():",e.message),console.log(e)})):null}bt()&&At();const Mt=()=>{var e;Rt(),function(){try{pt("pageView",{title:document.title,referrer:document.referrer,userAgent:navigator.userAgent,url:window.location.href,host:window.location.host,path:window.location.pathname,query:window.location.search,hash:window.location.hash,viewportWidth:document.documentElement.clientWidth,viewportHeight:document.documentElement.clientHeight})}catch(e){console.log("unable to log page view:",e.message)}}(),function(){const e=he.local.getItem("OptiMonkVisitorAttributes"),t={};kt.forEach((n=>{e&&void 0!==e[n]&&(t[n]=e[n])})),pt("visitorData",t)}(),window.Shopify&&window.Shopify.Checkout&&Ct.includes(window.Shopify.Checkout.page)&&window.Shopify.checkout&&pt("eoo",t({orderId:window.Shopify.checkout.order_id.toString(),total:parseFloat(window.Shopify.checkout.total_price),currency:window.Shopify.checkout.currency,shopifyCurrency:window.Shopify.currency.active,platform:"shopify",deviceType:OptiMonkRegistry.isMobile?"mobile":"desktop"},window.Shopify.checkout.discount&&{total_discount:parseFloat(window.Shopify.checkout.discount.amount)},(null==(e=window.Shopify.checkout.discount)?void 0:e.code)&&{discount_code:window.Shopify.checkout.discount.code})),window.ShopRenter&&window.ShopRenter.page&&"checkout/success"===window.ShopRenter.page.route&&window.ShopRenter.lastOrder&&pt("eoo",{orderId:window.ShopRenter.lastOrder.id,total:window.ShopRenter.lastOrder.total,currency:window.ShopRenter.lastOrder.currency,platform:"shoprenter",deviceType:OptiMonkRegistry.isMobile?"mobile":"desktop"}),ht(),window.JFClientSDK.v2.go().catch((function(e){console.error("An error occurred during initial JFClientSDK request:",e.message),console.error(e)})),function(e){if(OptiMonkRegistry.productChangeInterval&&clearInterval(OptiMonkRegistry.productChangeInterval),!(e=e||H()))return;const t={productId:e.productId,variantId:e.variantId};window.ShopifyAnalytics&&(OptiMonkRegistry.productChangeInterval=setInterval((function(){const e=H();e&&e.variantId&&t.variantId!==e.variantId&&(t.productId=e.productId,t.variantId=e.variantId,console.log("Detected Shopify variant change."),Rt(!0))}),1e3))}()},Tt="optiMonkExperiments",xt={init(){if(!OptiMonkRegistry.experimentsInitialized){let e=this.readCookie();e&&(e=this.cleanupOldExperimentsFromCookie(e)),OptiMonkRegistry.experiments.length&&(this.setVisitorGroups(e),this.runJsSnippets()),this.reportToGA(),OptiMonkRegistry.experimentsInitialized=!0}},initSafe(){try{this.init()}catch(e){console.error("[frontend] Experiments error",e)}},gaWithRetry(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o{this.gaWithRetry(e,...n)}),1e3)}else window.ga.getAll().forEach((e=>{const t=e.get("name");window.ga(t+".send",...n)}))},reportToGA(){const e=xt.readCookie();let t="";if(e&&e.length&&e.forEach((e=>{const n=e.split("_"),o=n[1],r=OptiMonkRegistry.experiments.find((e=>e._id===o));if(r){var i;const e=n[3],o=null==(i=r.groups.find((t=>t._id.toString()===e.toString())))?void 0:i.name;""!==t&&(t+="; "),t=t+"experiment: "+r.name+", group: "+o}})),t){const e=0;this.gaWithRetry(e,"event","OptiMonk","visitorInExperiment",t,{nonInteraction:1})}},readCookie(){const e=ee.local.getItem(Tt);return e?JSON.parse(e):null},cleanupOldExperimentsFromCookie(e){const t=JSON.parse(JSON.stringify(e));return e.forEach(((e,n)=>{const o=e.split("_")[1];OptiMonkRegistry.experiments.some((e=>e._id===o))||t.splice(n,1)})),ee.local.setItem(Tt,t),t},inVisitorGroupPerExperiment:(e,t)=>null==e?void 0:e.some((e=>e.startsWith("experiment_"+t._id))),sortToGroupByTrafficShare(e){const t=Math.floor(1e3*Math.random()*e.groups.length)+1;let n=0;for(const o of e.groups)if(n+=1e3*o.trafficShare,t<=n)return"experiment_"+e._id+"_group_"+o._id.toString()},runJsSnippet(e,t){try{new Function(t)(),console.log("[frontend] JS snippet run for experiment:",e)}catch(t){console.error("[frontend] Experiment JS snippet error.",e,t)}},runJsSnippets(){const e=this.readCookie();null==e||e.forEach((e=>{var t,n;const o=e.split("_"),r=o[1],i=o[3],s=null==(t=OptiMonkRegistry.experiments)?void 0:t.find((e=>e._id===r)),a=null==s||null==(n=s.groups)?void 0:n.find((e=>e._id===i));null!=a&&a.jsSnippet&&this.runJsSnippet(e,a.jsSnippet)}))},setVisitorGroups(e){const t=[];OptiMonkRegistry.experiments.forEach((n=>{this.inVisitorGroupPerExperiment(e,n)||t.push(this.sortToGroupByTrafficShare(n))})),t.length&&ee.local.setItem(Tt,[...e||[],...t])}},Nt=()=>{const e=G();function t(){try{if(document.removeEventListener("jetfabricLoaded",t),!OptiMonkRegistry.account||!window.JFClientSDK)return;let n;const o=Me.getInfo();let r=o.type,i=o.shopId||window.location.host;window.ShopifyAnalytics?n=F(window.ShopifyAnalytics,"meta.page.customerId"):window.ShopRenter&&(n=F(window.ShopRenter,"customer.userId")),58417===OptiMonkRegistry.account?(i="blendjet.myshopify.com",r="shopify"):88202===OptiMonkRegistry.account&&(i="rugby-is-life.myshopify.com",r="shopify"),n=n?""+n:void 0;const s=(()=>{const e=xt.readCookie(),t=[];return e&&e.length&&e.forEach((e=>{const n=e.split("_");t.push({experimentId:n[1],groupId:n[3]})})),JSON.stringify(t)})();if(window.JFClientSDK.v2.setAppId("optimonk").setFeatureState("INDEXEDDB_EVENTS",OptiMonkRegistry.jfIDBStoreEnabled).registerCustomerAddress({provider:"optimonk",providerServiceId:""+OptiMonkRegistry.account,customerAddress:OptiMonkRegistry.clientId||null,addressType:"deviceId"}).registerCustomerAddress({provider:r,providerServiceId:i,customerAddress:n||null,addressType:"customerId"}).setUserSessionSate({visitorInExperiment:s}),"shopify"===r){const e=ee.local.getItem("_shopify_y");e&&window.JFClientSDK.v2.registerCustomerAddress({provider:"shopify",providerServiceId:i,customerAddress:e,addressType:"deviceId"})}const a=ee.local.getItem("__kla_id");if(a)try{const t=JSON.parse(window.atob(a));if(t.$exchange_id){var e;const n=(null==(e=window._learnq)?void 0:e.account())||t.$exchange_id.split(".").pop();n||console.error("OptiMonk: unable to acquire Klaviyo account id"),window.JFClientSDK.v2.registerCustomerAddress({provider:"klaviyo",providerServiceId:n,addressType:"customerId",customerAddress:t.$exchange_id}),window.JFClientSDK.v2.addClientStateProperty("klaviyoExchangeId",t.$exchange_id)}}catch(e){u.sendException(e)}At(),Mt()}catch(e){console.error("Failed to initialize JF:",e.message),console.error(e)}}e&&q("webSelector",OptiMonkRegistry.pncJsScriptUrl+"?t="+(new Date).getTime()),document.addEventListener("jetfabricLoaded",t),document.addEventListener("webSelectorLoaded",(function(){try{document.removeEventListener("webSelectorLoaded",t);const e=window.OptiMonkRegistry.pncConfig;window.PNC.initPNC(e)}catch(e){console.error("Failed to initialize WebSelector:",e.message),console.error(e)}})),window.JFClientSDK?Mt():q("jetfabric",OptiMonkRegistry.jfJsScriptUrl),ge.load().then((function(){!e&&L()&&U()}))},Lt={isShopifyShop:()=>void 0!==window.ShopifyAnalytics&&void 0!==window.Shopify,isProductPage:()=>"product"===window.ShopifyAnalytics.meta.page.pageType,getProductId:()=>window.ShopifyAnalytics.meta.product.id,getVariantId:()=>window.ShopifyAnalytics.meta.selectedVariantId,getProductPageData(){return{product_id:this.getProductId()}},isCollectionPage:()=>"collection"===window.ShopifyAnalytics.meta.page.pageType,isCheckoutPage(){var e,t;return"show"===(null==(e=window.Shopify)||null==(t=e.Checkout)?void 0:t.page)},getResourceId:()=>window.ShopifyAnalytics.meta.page.resourceId,getResourceType:()=>window.ShopifyAnalytics.meta.page.resourceType,getShopName:()=>window.Shopify.shop||window.Shopify.Checkout.apiHost,getShopCurrency:()=>window.ShopifyAnalytics.meta.currency,applyCheckoutDiscountCode:e=>new n.native.Promise((t=>{const n=document.querySelector('[data-discount-field], [name="reductions"]');n&&(n.value=e,n.dispatchEvent(new Event("input",{bubbles:!0})),n.form)?setTimeout((()=>{n.form.dispatchEvent(new Event("submit",{bubbles:!0})),t(!0)}),0):t(!1)}))};class Pt{getJF(){return window.JFClientSDK&&window.JFClientSDK.v2}isEnabled(){return void 0!==this.getJF()}reportEvent(e,t){const n=Pt.reportEventMap[e];n&&pt(n,{campaignId:""+t.getId(),variantId:t.getCreativeId(),deviceType:OptiMonkRegistry.isMobile?"mobile":"desktop"})}sendNonInteractionEvent(e,t,n,o){this.isEnabled()&&this.reportEvent(t,o)}sendInteractionEvent(e,t,n,o){this.isEnabled()&&this.reportEvent(t,o)}}Pt.reportEventMap={"close(x)":"eoc"};const Dt="gtag",jt="ga";class Ft{constructor(e){var t;this.fnName=e;const o=(null==n||null==(t=n.config)?void 0:t.analytics)||{};o.trackerName?this.trackerName=o.trackerName+".":this.trackerName=""}checkFnAvailability(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o{this.checkFnAvailability(e,...n)}),1e3)}ga(){for(var e=arguments.length,t=new Array(e),n=0;nVt.get(e)||Vt.get("default"),getAll(){const e=[];return Vt.forAll(((t,n)=>{"default"!==t&&e.push(n)})),e}},Kt={OPERATION_FILLED:"filled",OPERATION_SHOWED:"showed",OPERATION_NO:"no",OPERATION_CLOSE_X:"closeX",report(e,t){if(!Kt.isEnabled(t))return;const n=t.getName()+" - "+t.getCreativeName();Kt.getEnabledAdapters().forEach((o=>{Kt.send(e,o,n,t)}))},reportCustomEvent(e,t){Kt.getEnabledAdapters().forEach((n=>{Kt.send(e,n,t)}))},isEnabled:e=>1===e.getAnalytics().status,getEnabledAdapters:()=>Ht.getAll().filter((e=>e.isEnabled())),send(e,t,n,o){const r=OptiMonkRegistry.brand;let i;switch(e){case Kt.OPERATION_FILLED:i="filled",t.sendInteractionEvent(r,i,n,o);break;case Kt.OPERATION_SHOWED:i="shown",t.sendNonInteractionEvent(r,i,n,o);break;case Kt.OPERATION_NO:i="no",t.sendNonInteractionEvent(r,i,n,o);break;case Kt.OPERATION_CLOSE_X:i="close(x)",t.sendNonInteractionEvent(r,i,n,o);break;default:t.sendNonInteractionEvent(r,e,n,o)}}},Xt=e=>({INITIAL_TITLE:e,BLINKING_TIME:3e3,TIMEOUT_CAME_BACK:3e3,INTERVAL:null,getInitialTitle(){return this.INITIAL_TITLE},getTitle:()=>document.title,setTitle(e){document.title=e},startIdle(e){this.INTERVAL=setInterval((()=>{this.getTitle()===this.INITIAL_TITLE?this.setTitle(e):this.setTitle(this.INITIAL_TITLE)}),this.BLINKING_TIME)},stopIdle(){clearInterval(this.INTERVAL)},async sendEventAfterCameBack(){var e;if(!(null==(e=window.JFClientSDK)?void 0:e.v2))throw new Error("Unable to send event: JFClientSDK is not loaded");try{pt("flashingBrowserTab:userCameBack"),Kt.reportCustomEvent("userCameBack","flashing browser tab notification")}catch(e){throw new Error("unable to log flashingBrowserTab:",e.message)}},visibilityChanged(e){document.addEventListener("visibilitychange",(()=>{document.hidden?(this.startIdle(e),Kt.reportCustomEvent("userLeave","flashing browser tab notification")):(this.stopIdle(),this.setTitle(this.INITIAL_TITLE),setTimeout((async()=>{try{await this.sendEventAfterCameBack()}catch(e){throw new Error("Unable to send events, error: ",e)}}),this.TIMEOUT_CAME_BACK))}))},init(){const{isMobile:e}=OptiMonkRegistry,t=n.getExperimentalSetting("BrowserTabNotification");if(!t)return;const{active:o,browserTabText:r,cookieTargetActive:i,cookieTarget:s}=t,a=ee.local.hasItem(s);o&&(i&&a||!e&&!i)&&this.visibilityChanged(r)},initSafe(){try{this.init()}catch(e){console.error("[frontend] BrowserTabNotification error",e)}}}),Wt={doMagic(e){const t=Math.floor(100*Math.random())+1;e.sort(((e,t)=>e.ratio-t.ratio));let n=0;for(const o of e)if(n+=parseInt(o.ratio,10),t<=n)return o},_checkCookies(e){var t;return Array.isArray(e)||(e=[e]),null==(t=e.find((e=>ee.local.hasItem(e.cookie))))?void 0:t.cookie},setRandomCookie(e,t){const{cookie:n}=this.doMagic(e);return ee.local.setItem(n,t),n},checkAndSetup(e,t){const{cookies:n,jsSnippet:o}=e;let r=this._checkCookies(n);var i;(r||(r=this.setRandomCookie(n,t)),o)&&this._runJs(o,{cohort:r,splitName:null==(i=r.match(/.*_([a-zA-Z0-9]+)$/))?void 0:i[1]})},_runJs(e,t){let{cohort:n,splitName:o}=t;if(e&&"string"!=typeof e)console.warn("Invalid JS snippet passed to JS executor, type:",typeof e);else try{new Function("\n var cohort = "+JSON.stringify(n)+";\n var splitName = "+JSON.stringify(o)+";\n var gaRetry = 0;\n var ga = function() {\n var args = arguments;\n if (typeof window['ga'] === 'function') {\n return window['ga'].apply(window, args);\n }\n\n return new Promise(function (resolve, reject) {\n if (++gaRetry <= 5) {\n setTimeout(function() {\n resolve(ga.apply(null, args));\n }, 1000);\n } else {\n reject(new Error('ga() is not loaded.'));\n }\n });\n };\n "+e+"\n ")()}catch(e){console.error("[frontend] Campaign A/B test JS snippet error.")}},init(){const e=n.getExperimentalSetting("CampaignsAbTest"),t=e&&e.testCases;if(!t)return;const o=Date.now();for(let e=0;e{n.preloadInitialized=!0,n.hasError=!1;try{Wt.initSafe(),xt.initSafe(),Xt(document.title).initSafe(),n.ShopifyAdapter=Lt,n.Util.checkVariable("ShopifyAnalytics",20).then((function(){n.triggerEvent(document.querySelector("html"),"optimonk#shopify-vars-loaded",n.ShopifyAdapter)}),(function(){n.triggerEvent(document.querySelector("html"),"optimonk#shopify-vars-not-loaded")})),n.CartIntegration||(n.CartIntegration=new It),D(document.querySelector("html"),"optimonk#preload-initialized"),OptiMonkRegistry.isMobile&&OptiMonkRegistry.shouldSendTimeSpentOnPage&&Ge.init(),OptiMonkRegistry.needClientId&&function(){let e=ee.local.getItem("optiMonkClientId");e||(e=j(),ee.local.setItem("optiMonkClientId",e)),OptiMonkRegistry.clientId=e}(),OptiMonkRegistry.needSiteInfo&&setTimeout((function(){Le.initialize(),Le.send()}),5e3),function(){if(OptiMonkRegistry.needKlaviyoInfo){let e,t=10;setTimeout((function(){const n=setInterval((function(){e=Le.getKlaviyoInfo().isKlaviyoDetected,t--,(e||t<1)&&(Le.sendIsKlaviyoDetected(),clearInterval(n))}),1e3)}),5e3)}}(),Nt(),function(){if(window.Shopify&&window.Shopify.Checkout&&"thank_you"===window.Shopify.Checkout.page){const e=window.Shopify.checkout&&window.Shopify.checkout.discount&&window.Shopify.checkout.discount.code;if(e){const t=n.Storage.local.getItem("OptiMonkVisitorAttributes"),o=Object.entries(t).find((t=>{let[n,o]=t;return o===e&&"coupon_code"!==n}));o&&(delete t[o[0]],delete t[o[0]+"_data"]),n.Storage.local.setItem("OptiMonkVisitorAttributes",t)}}}(),Et(),30818!==OptiMonkRegistry.account&&58417!==OptiMonkRegistry.account||Ke(window,"error",u.sendEventError),58417===OptiMonkRegistry.account&&setInterval((function(){if(!n.Visitor)return;const e=n.Visitor.createAdapter();e.Cart.clear();(F(window.$nuxt,"$store.state.cart.lineItems")||[]).forEach((function(t){const n=t.variant;e.Cart.add(t.id,{handle:t.handle,quantity:t.quantity,price:parseFloat(n.price),line_price:parseFloat(n.compareAtPrice),product_id:t.id,product_title:t.title,sku:n.sku,title:t.title,url:t.url})}))}),200)}catch(e){u.sendException(e),r.error(e),u.sendException("preload",e)}})()}();